<?php

define('NTD','0.0.1');

header("charset:utf-8");
//错误配置
ini_set("display_errors",1);
error_reporting(E_ALL^E_NOTICE);

ini_set('date.timezone','PRC');

define("__ROOT__" , str_replace("\\","/",dirname(__FILE__)));

$config = require_once __ROOT__ . '/Conf/config.php';
include_once __ROOT__ . '/functions.php';
include_once __ROOT__ . "/Controller/AutoController.class.php";

//注册自动加载
spl_autoload_register("Controller\\AutoController::load");

Vendor\Register::set("config" , $config);

$db = Vendor\Database::getInstance();

Vendor\Register::set('db',$db);

if(empty($_GET['m']) || empty($_GET['f']) || !is_file(__ROOT__ . '/Controller/' . $_GET['m'] . 'Controller.class.php')) {
    exit(json_encode(array(
        'status' => 102,
        'error' => '非法请求!'
    )));
} else {
    $m = ucwords($_GET['m']);
    $f = $_GET['f'];
    $t = $_GET['t'];
    $controller = 'Controller\\' . $m . 'Controller';
    $handler = new $controller ($t);
    $handler -> {$f} ();
}



